home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Trading on the Edge
/
Trading On The Edge - CD-ROM Toolkit (Wayzata Technology)(2031)(1994).bin
/
mac
/
Mac_Files
/
Software Utilities
/
NN PreProcessing
/
FINCMD.H
< prev
next >
Wrap
C/C++ Source or Header
|
1992-09-24
|
5KB
|
140 lines
/* 21:30 03-Jan-92 (fincmd.h) Command Line Parser Structures */
#ifndef FINCMDH
#define FINCMDH
/************************************************************************
* Copyright(C) 1992 NeuralWare, Inc. *
* Penn Center West, IV-227, Pittsburgh, PA 15276 *
* *
* All rights reserved. No part of this program may be reproduced, *
* stored in a retrieval system, or tramsmitted, in any form or by any *
* means, electronic, mechanical, photocopying, recording or otherwise *
* without the prior written permission of the copyright owner, *
* NeuralWare, Inc. *
************************************************************************
*/
/************************************************************************
* *
* fincmd - Command Line Parser & Action Routine Manager *
* *
************************************************************************
Tasks:
Integrate syntax errors with standard error handling system
Integrate help system with standard error handling system
*/
#ifndef FAST
#ifdef SUN
#define FAST register
#else
#define FAST
#endif
#endif
#ifndef ARGS
#ifdef SUN
#define ARGS(x) ()
#else
#define ARGS(x) x
#endif
#endif
#ifndef ASof
#define ASof(x) ((int)(sizeof(x)/sizeof(x[0])))
#endif
typedef int (*ACTR) ARGS((struct _cmd *, long, FILE *));
#define SETBIT(x) ( ((x)<0||31<(x))? 0:(1L<<(x)) )
#define ISBIT(x,bit) ( ((x)&SETBIT(bit)) != 0? 1:0 )
/* --- Universal Pointer Union --- */
typedef union _uvp { /* universal pointer union */
char *cP; /* character */
short *sP; /* short */
long *lP; /* long */
int *iP; /* int */
void *vP; /* void */
float *fP; /* float */
double *dP; /* double */
} UVP;
/* --- Translation of literals to values and vice versa --- */
typedef struct _lit {
char *LNameCP; /* literal name */
double LValueD; /* resulting value as float */
} LIT;
/* --- Control structure for a single data value --- */
typedef struct _input {
char *IValP; /* value pointer */
LIT *ILitTabP; /* literal table pointer */
char IInFuncC; /* input function */
#define IO_NAK 0x00 /* no action */
#define IO_LST 0x01 /* CLitTabP -> Input structure */
#define IO_INT 0x02 /* integer */
#define IO_BIT 0x03 /* integer (or of bits) */
#define IO_FLT 0x04 /* real */
#define IO_STR 0x05 /* quoted string */
#define IO_FNM 0x06 /* file name */
#define IO_FLD 0x07 /* field name */
#define IO_DTE 0x08 /* date field */
#define IO_MASK 0x0f /* mask for input/output type */
#define IO_OPT 0x10 /* optional item */
#define IO_DSP 0x20 /* force display on action routine */
#define IO_LITONLY 0x40 /* ONLY use literals */
char IOutFuncC; /* output function */
#define FMT_INTS 0x00 /* %ld */
#define FMT_INTU 0x01 /* %lu */
#define FMT_HEXU 0x02 /* %lx */
#define FMT_OCTU 0x03 /* %lo */
#define FMT_FLT0 0x04 /* %.0f */
#define FMT_FLT1 0x05 /* %.1f */
#define FMT_FLT2 0x06 /* %.2f */
#define FMT_FLT3 0x07 /* %.3f */
#define FMT_FLT4 0x08 /* %.4f */
#define FMT_FLT5 0x09 /* %.5f */
char ISizeI; /* size of item */
char IItemsI; /* # of items */
} INPUT;
/* --- Macros for building a "INPUT" data-descriptor structure --- */
#define IVAL( v,inf,outf,xlt) /* single value */ \
{ (char *)&v, (LIT *)xlt, inf, outf, sizeof(v), 1 }
#define IVALA(v,inf,outf,xlt) /* array of values */ \
{ (char *)&v[0], (LIT *)xlt, inf, outf, sizeof(v[0]), sizeof(v)/sizeof(v[0]) }
#define ISTR( v,inf) /* string */ \
{ (char *)&v[0], (LIT *)0, inf, 0, sizeof(v), 1 }
#define ILIST( list, inf ) /* list */ \
{ (char *)&list[0], 0, IO_LST|(inf), 0, 0, 0 }
#define INUL /* end of list */ { (char *)0 }
#define IACTR0 /* act rtne no args */ { (char *)0, (LIT *)0, IO_DSP, 0, 0, 0 }
/* --- Command Structure --- */
typedef struct _cmd {
char *CNameCP; /* name of command / variable */
char *CHelpCP; /* description of item */
ACTR CActRtnP; /* action routine */
INPUT CInS; /* input Structure */
} CMD;
/************************************************************************
* *
* Global Routines associated with fincmd.c *
* *
************************************************************************
For examples of how to use both of these routines, see the
test routine at the end of fincmd.c.
*/
int ParseLineI ARGS((char **,CMD *,FILE *,int));
int PrintTableI ARGS((CMD *,FILE *,char*,int));
int StoreValueI ARGS((char *,INPUT *,double));
#endif /* FINCMDH */